//
// Created by jiang on 2021/12/20.
//
#include "scheduler.h"

scheduler_t scheduler;

void SCH_Init(scheduler_t *pHandle) {
    pHandle->ms2 = 0;
    pHandle->ms5 = 0;
    pHandle->ms10 = 0;
    pHandle->ms20 = 0;
    pHandle->ms50 = 0;
    pHandle->ms100 = 0;
    pHandle->ms200 = 0;
    pHandle->ms1000 = 0;
}


void SCH_TickScheduler(scheduler_t *pHandle) {
    pHandle->ms2++;
    pHandle->ms5++;
    pHandle->ms10++;
    pHandle->ms20++;
    pHandle->ms50++;
    pHandle->ms100++;
    pHandle->ms200++;
    pHandle->ms1000++;

    if (pHandle->ms2 >= 2) {
        pHandle->ms2 = 0;
        pHandle->Hz500 = 1;
    }
    if (pHandle->ms5 >= 5) {
        pHandle->ms5 = 0;
        pHandle->Hz200 = 1;
    }
    if (pHandle->ms10 >= 10) {
        pHandle->ms10 = 0;
        pHandle->Hz100 = 1;
    }
    if (pHandle->ms20 >= 20) {
        pHandle->ms20 = 0;
        pHandle->Hz50 = 1;
    }
    if (pHandle->ms50 >= 50) {
        pHandle->ms50 = 0;
        pHandle->Hz20 = 1;
    }
    if (pHandle->ms100 >= 100) {
        pHandle->ms100 = 0;
        pHandle->Hz10 = 1;
    }
    if (pHandle->ms200 >= 200) {
        pHandle->ms200 = 0;
        pHandle->Hz5 = 1;
    }
    if (pHandle->ms1000 >= 1000) {
        pHandle->ms1000 = 0;
        pHandle->Hz1 = 1;
    }
}






